package zdm.core.aop;

import java.lang.reflect.Method;

/**
 * ProceedingJoinPoint 的具体实现类
 */
public class ZdmProceedingJoinPoint implements ProceedingJoinPoint {
    private final Object target;
    private final Method method;
    private final Object[] args;

    public ZdmProceedingJoinPoint(Object target, Method method, Object[] args) {
        this.target = target;
        this.method = method;
        this.args = args;
    }

    @Override
    public Object proceed() throws Throwable {
        return method.invoke(target, args);
    }

    @Override
    public Object[] getArgs() {
        return args;
    }

    @Override
    public Object getTarget() {
        return target;
    }

    /**
     * 新增: 实现接口中的新方法
     *
     * @return 直接返回我们内部保存的 Method 对象
     */
    @Override
    public Method getMethod() {
        return this.method;
    }
}